<template>
  <RecordLink :value="value"
              :link="url"
              :query="query"
              :target="target"
              :tag="tag"
              :copyable="copyVisable">
    <el-tooltip v-if="isTooltip"
                class="mr10"
                effect="dark"
                content="货物异常"
                placement="top">
      <icon-svg class-name="iconClass"
                icon-name="yichang" />
    </el-tooltip>
  </RecordLink>
</template>

<script>

import RecordLink from "@basic/RecordLink.vue"

export default {
  name: "LinkColumn",
  components: {
    RecordLink
  },
  props: {
    value: {
      type: String,
      default: null
    },
    row: {
      type: Object,
      default: () => { }
    },
    paramsData: {
      type: Array,
      default: () => []
    },
    linkType: {
      type: Number,
      default: 0
    },
    //拆单、合单标记
    orderType: {
      type: Number,
      default: 0
    },
    combine: {
      type: Number,
      default: 0
    }, //合单标识
    exception: {
      type: Number,
      default: 0
    }, //货物异常标识
    // 复制icon 显示
    copyVisable: {
      type: Boolean,
      default: () => true
    },
    custom: {
      type: Object,
      default: () => null
    },
    url: [String]
  },
  computed: {
    isTooltip () {
      return this.exception && this.row?.goodsException
    },
    tag () {
      if (this.orderType === 1 && this.row.divide) {
        return "拆";
      } else if (this.combine === 1 && this.row.combineContractNo) {
        return "合";
      }
      return ""; // 如果都不满足条件，返回空字符串
    },
    query () {
      let paramsData = {};
      this.paramsData.forEach((element) => {
        paramsData[element] = this.row[element];
      });
      // 如果this.custom存在, 则把它的元素合并为数据源
      if (this.custom) {
        paramsData = { ...paramsData, ...this.custom }
      }
      return paramsData;
    },
    target () {
      return this.linkType ? '' : "_blank";
    }
  }
};
</script>
